package com.googlecode.horncomb.core.order;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import org.springframework.util.Assert;

/**
 * 排序定义
 * @author Daniel
 * @version $LastChangedRevision$
 */
public class OrderImpl implements Order, Serializable {
	private static final long serialVersionUID = -8060540944644138604L;

	public OrderImpl() {
		super();
	}

	public OrderImpl(SortToken... sorts) {
		super();
		for (SortToken s : sorts) {
			this.getSorts().add(s);
		}
	}

	public List<SortToken> sorts = new ArrayList<SortToken>();

	/**
	 * @see com.googlecode.horncomb.core.order.Order#addSortToken(com.googlecode.horncomb.core.order.SortToken)
	 */
	public Order addSortToken(SortToken sort) {
		Assert.notNull(sort);
		Assert.hasText(sort.getProperty());
		this.sorts.add(sort);
		return this;
	}

	/**
	 * @see com.googlecode.horncomb.core.order.Order#getSorts()
	 */
	public List<SortToken> getSorts() {
		return sorts;
	}

	public void setSorts(List<SortToken> sorts) {
		Assert.notNull(sorts);
		this.sorts = sorts;
	}
}
